<?php
require_once("UploadedFile.php");

/**
 * Attributes factory storing files sent by client.
 */
class RequestParametersFiles extends Component {
	public function __construct() {
		if(sizeof($_FILES)>1) {
			foreach($_FILES as $strName=>$tblValues1) {
				if(is_array($tblValues1["tmp_name"])) {
					foreach($tblValues1["tmp_name"] as $intIndex=>$strValue) {
						if($tblValues1["error"][$intIndex]>0) continue;
						$objUploadedFile = new UploadedFile();
						$objUploadedFile->setName($tblValues1["name"][$intIndex]);
						$objUploadedFile->setLocation($tblValues1["tmp_name"][$intIndex]);
						$objUploadedFile->setContentType($tblValues1["type"][$intIndex]);
						$objUploadedFile->setSize($tblValues1["size"][$intIndex]);
						$this->tblAttributes[$strName][$intIndex] = $objUploadedFile; 
					}
				} else {
					if($tblValues1["error"]>0) continue;
					$objUploadedFile = new UploadedFile();
					$objUploadedFile->setName($tblValues1["name"]);
					$objUploadedFile->setLocation($tblValues1["tmp_name"]);
					$objUploadedFile->setContentType($tblValues1["type"]);
					$objUploadedFile->setSize($tblValues1["size"]);
					$this->tblAttributes[$strName] = $objUploadedFile; 
				}
			}
		}
	}	
}